﻿using System.Windows.Input;
using HeritageAcademy.Models.DataModels;
using HeritageAcademy.Shared;

namespace HeritageAcademy.Models.ViewModels
{
    public class CourseLocationViewModel : ViewModelBase<CourseLocation>
    {
        #region Parameters 
        private readonly CourseViewModel _bookViewModel;
        private int? _currentPageNumber;
        private bool _isHighlight;
        #endregion

        #region Ctor 
        public CourseLocationViewModel(CourseLocation location, CourseViewModel book)
            : base(location)
        {
            _bookViewModel = book;
        }
        #endregion

        #region Properties 
        public int? CurrentPageNumber
        {
            get { return _currentPageNumber; }
            set
            {
                _currentPageNumber = value;
                RaisePropertyChanged("CurrentPageNumber");
            }
        }

        public bool IsHighlight
        {
            get { return _isHighlight; }
            set
            {
                _isHighlight = value;
                RaisePropertyChanged("IsHighlight");
            }
        }
        #endregion Properties 

        #region GotoLocationCommand
        private RelayCommand _gotoLocationCommand;

        public ICommand GotoLocationCommand
        {
            get
            {
                return _gotoLocationCommand ?? (_gotoLocationCommand = new RelayCommand(param => GotoLocation(),
                                                                                        param => CanGotoLocation()));
            }
        }

        private void GotoLocation()
        {
            if (_bookViewModel != null)
                _bookViewModel.CurrentLocation = Model;
        }

        private bool CanGotoLocation()
        {
            return _bookViewModel != null;
        }
        #endregion
    }
}